import Vue from 'vue'
import Router from 'vue-router'
// in development env not use Lazy Loading,because Lazy Loading too many pages will cause webpack hot update too slow.so only in production use Lazy Loading
/* layout */
import Layout from '../views/layout/Layout'

const _import = require('./_import_' + process.env.NODE_ENV)
Vue.use(Router)
export const constantRouterMap = [
  {path: '/login', component: _import('login/index'), hidden: true },
  {path: '/startapp', component: _import('app/startapp'), hidden: true},
  {path: '/404', component: _import('404'), hidden: true},
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: '首页',
    hidden: true,
    children: [{
      path: 'dashboard', component: _import('dashboard/index')
    }]
  }
]
export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
})
export const asyncRouterMap = [
  // {
  //   path: '/system',
  //   component: Layout,
  //   redirect: '/system/article',
  //   name: '功能模块',
  //   meta: {title: '功能模块', icon: 'tree'},
  //   children: [
  //     {
  //       path: 'article',
  //       name: '文章',
  //       component: _import('article/article'),
  //       meta: {title: '文章', icon: 'example'},
  //       menu: 'article'
  //     },
  //   ]
  // },
  {
    path: '/user',
    component: Layout,
    redirect: '/user/',
    name: '',
    meta: {title: '用户管理', icon: 'table'},
    children: [
      {
        path: 'wxuser', name: '用户管理', component: _import('user/wxuser'), meta: {title: '用户管理', icon: 'user'}, menu: 'user'
      }
    ]
  },{
    path: '/code',
    component: Layout,
    redirect: '/code/',
    name: '',
    meta: {title: '激活码管理', icon: 'table'},
    children: [
      {
        path: 'list', name: '激活码管理', component: _import('code/list'), meta: {title: '激活码管理', icon: 'code'}, menu: 'code'
      }
    ]
  }, {
    path: '/admin',
    component: Layout,
    redirect: '/admin/',
    name: '',
    meta: { title: '管理员列表', icon: 'table' },
    children: [
      {
        path: 'list', name: '管理员列表', component: _import('admin/list'), meta: { title: '管理员列表', icon: 'code' }, menu: 'admin'
      }
    ]
  },
  { path: '*', redirect: '/404', hidden: true }
]
